package springMVC.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class FirstController {

	@RequestMapping(value="/first",method=RequestMethod.GET)
	public String first() {
		System.out.println("first()成功!");
		return "success";
	}
	
	@RequestMapping(value="/first1",method=RequestMethod.GET)
	public String first1() {
		System.out.println("first1()成功!");
		return "success.jsp";
	}
	
	//参数传递
	@RequestMapping(value="/say",method=RequestMethod.GET)
	public String sayName(String name) {
		System.out.println(name);
		return "success";
	}
	
	//参数判断
	@RequestMapping(value="/age",method=RequestMethod.GET)
	public String sayAge(int age) {
		if(age!=18) {
			return "no18";
		}else {
			return "18";
		}
	}
	
	//多参传递
	@RequestMapping(value="/login",method=RequestMethod.GET)
	public String login(@RequestParam("name") String username,@RequestParam("password") String userPassword) {
		System.out.println("name="+username+";passowrd="+userPassword);
		return "success";
	}
}
